<?php

use think\migration\Migrator;
use think\migration\db\Column;

class CreateConfigTable extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $this->table('config', ['comment'=>'配置信息'])
            ->addColumn(Column::string('name', 30)->setComment('配置名'))
            ->addColumn(Column::string('title', 20)->setNullable()->setComment('中文名'))
            ->addColumn(Column::string('remark', 100)->setNullable()->setComment('配置说明'))
            ->addColumn(Column::string('type', 30)->setNullable()->setComment('配置类型'))
            ->addColumn(Column::text('value')->setNullable()->setComment('配置值'))
            ->addColumn(Column::tinyInteger('sort')->setDefault(0)->setNullable()->setComment('排序'))
            ->addColumn(Column::integer('create_time')->setComment('创建时间')->setNullable())
            ->addColumn(Column::integer('update_time')->setComment('修改时间')->setNullable())
            ->addColumn(Column::integer('delete_time')->setComment('删除时间')->setNullable())
            ->create();
    }
}
